package com.hyj.controller;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import com.hyj.entity.Fenye;
import com.hyj.entity.Students;
import com.hyj.entity.Users;
import com.hyj.service.StudentService;

@Controller
public class StudentController {
	@Autowired
	private StudentService studentService;
	@Autowired
	private Students student;
	@Autowired
	private Fenye<Students> fenye;
	//查询全部学生信息
	@RequestMapping(value="/getStu",method=RequestMethod.POST)
	@ResponseBody
	public Fenye<Students> getStuAll(Students student,Integer page,Integer rows){
		
		fenye.setPage((page-1)*rows);
		fenye.setPageSize(rows);
		fenye.setStudent(student);
		fenye = studentService.selectFenyeStu(fenye);
		System.out.println(fenye);
		return fenye;
		
	}
	//添加学生
	@RequestMapping(value="addStu",method=RequestMethod.POST)
	@ResponseBody
	public Integer addStu(Students student) {
		// TODO Auto-generated method stub
		return studentService.addStu(student);
	}
	//修改学生
	@RequestMapping(value="updateStu",method=RequestMethod.POST)
	@ResponseBody
	public Integer updateStu(Students student) {
		// TODO Auto-generated method stub
		return studentService.updateStu(student);
	}
	//查询所有用户
	@RequestMapping(value="selectUser",method=RequestMethod.POST)
	@ResponseBody
	public List<Users> selectUser() {
		// TODO Auto-generated method stub
		return studentService.selectUser();
	}
	//修改为失效
	@RequestMapping(value="upIsvaild",method=RequestMethod.POST)
	@ResponseBody

	public Integer upIsvaild(Students student) {
		// TODO Auto-generated method stub
		return studentService.upIsvaild(student);
	}
	//添加网络学生 
	@RequestMapping(value="addOnlineStu",method=RequestMethod.POST)
	@ResponseBody

	public Integer addOnlineStu(Students student) {
		// TODO Auto-generated method stub
		return studentService.addOnlineStu(student);
	}
	
	/**
	 * 修改为有效
	 * @param student
	 * @return
	 */
	@RequestMapping(value = "upvaild", method = RequestMethod.POST)
	@ResponseBody
	public Integer upvaild(Students student) {
		// TODO Auto-generated method stub
		return studentService.upvaild(student);
	}

}
